
cmake_minimum_required(VERSION 3.20)

# set(CMAKE_CXX_STANDARD 11)
# set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_CXX_STANDARD 14)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)


# Find requirements
find_package(fastcdr REQUIRED)
find_package(fastrtps 2.13 REQUIRED)
find_package(foonathan_memory REQUIRED)

message(STATUS "Configuring fastddsProtocol...")
# 先调用get_property将这个property读取到一个变量中(variable)INCLUDE_OPENCL 
get_property(BIN GLOBAL PROPERTY "BIN_DIR" ) 
# 显示INCLUDE_OPENCL 
MESSAGE(STATUS "DDSBIN :${BIN}")



file(GLOB DDS_LIB_SOURCES_CXX "./idl/*.cxx")
file(GLOB DDS_LIB_SOURCES_CPP "./idl/*.cpp")
file(GLOB USER_SOURCES_CPP "*.cpp")
        
        
if (debug STREQUAL "ON" OR debug STREQUAL "on")
    add_library(ddsProtocol_lib STATIC ${DDS_LIB_SOURCES_CXX} ${DDS_LIB_SOURCES_CPP})
    target_link_libraries(ddsProtocol_lib fastrtps fastcdr foonathan_memory)

    add_library(ddsProtocol STATIC ${USER_SOURCES_CPP})
    target_link_libraries(ddsProtocol fastrtps fastcdr foonathan_memory ddsProtocol_lib)
    install(TARGETS ddsProtocol 
    LIBRARY DESTINATION ${BIN} )
else()

    add_library(ddsProtocol SHARED ${USER_SOURCES_CPP} ${DDS_LIB_SOURCES_CXX} ${DDS_LIB_SOURCES_CPP})
    target_link_libraries(ddsProtocol libfastrtps.so libfastcdr.so foonathan_memory)
    install(TARGETS ddsProtocol 
    LIBRARY DESTINATION ${BIN} )
endif()